package com.proj.hot.activity;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;

import com.proj.hot.GlobalParams;
import com.proj.hot.widget.XWDialogPayTips;

/**
 * 基activity  ,,
 *
 */
public class TipsBaseActivity extends FragmentActivity {

    private final String TAG = getClass().getSimpleName();
    PayTipsReceiverS payTipsReceiverS;
    XWDialogPayTips xwDialogPayTips;

    @Override
    protected void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);

        IntentFilter filter = new IntentFilter(
                "payTips");
        payTipsReceiverS = new PayTipsReceiverS();
        registerReceiver(payTipsReceiverS, filter);

    }

    class PayTipsReceiverS extends BroadcastReceiver {

        @Override
        public void onReceive(Context arg0, Intent arg1) {


            if (GlobalParams.IS_LOGIN){




                if (GlobalParams.user_Residualduration<=0){

                    GlobalParams.user_paytype="2";
                    Intent intent = new Intent(arg0.getApplicationContext(), PayActivity.class);
                    startActivity(intent);
                }else{
                    if(xwDialogPayTips==null){
                        xwDialogPayTips=new XWDialogPayTips(arg0,"");
                    }

                    if(!xwDialogPayTips.isShowing()){
                        xwDialogPayTips.show();
                    }
                }

            }



        }

    }



    @Override protected void onResume() {
        IntentFilter filter = new IntentFilter("payTips");
        registerReceiver(payTipsReceiverS, filter);
        super.onResume();
    }

    @Override protected void onPause() {
        unregisterReceiver(payTipsReceiverS);
        super.onPause();
    }


}
